package com.example.design.shejimoshi.structure.compose.组合模式链式任务;

/**
 * LeafTask 类，实现了 Task 接口，表示具体的任务
 */
public class LeafTask implements Task {
    private String name;  
  
    public LeafTask(String name) {  
        this.name = name;  
    }  
  
    @Override  
    public void execute() {  
        System.out.println("Executing leaf task: " + name);  
    }  
  
    @Override  
    public void add(Task task) {  
        throw new UnsupportedOperationException("Leaf tasks cannot have subtasks");  
    }  
  
    @Override  
    public void remove(Task task) {  
        throw new UnsupportedOperationException("Leaf tasks cannot have subtasks");  
    }  
  
    @Override  
    public boolean isLeaf() {  
        return true;  
    }  
}  